package com.example.tests.lesson1_hw2;

import java.util.Arrays;

public class ContactModel {

	public String firstName;
	public String lastName;
	public String address;
	public String home;
	public String mobile;
	public String work;
	public String email;
	public String email2;
	public String address2;
	public String home2;
	public String bDay = "-";
	public String bMonth = "-";
	public String bYear;
	public String new_group = "[none]";

	private String[] monthes;

	private String[] setMonthes() {
		String[] temp = { "-", "January", "February", "March", "April", "May",
				"June", "July", "August", "September", "October", "November",
				"December" };

		return temp;
	}

	public ContactModel() {
		monthes = setMonthes();
	}

	public ContactModel setGroup(String value) {
		this.new_group = value;
		return this;
	}

	public ContactModel setFirstName(String value) {
		this.firstName = value;
		return this;
	}

	public ContactModel setLastName(String value) {
		this.lastName = value;
		return this;
	}

	public ContactModel setAddress(String value) {
		this.address = value;
		return this;
	}

	public ContactModel setHome(String value) {
		this.home = value;
		return this;
	}

	public ContactModel setMobile(String value) {
		this.mobile = value;
		return this;
	}

	public ContactModel setWork(String value) {
		this.work = value;
		return this;
	}

	public ContactModel setEmail(String value) {
		this.email = value;
		return this;
	}

	public ContactModel setEmail2(String value) {
		this.email2 = value;
		return this;
	}

	public ContactModel setAddress2(String value) {
		this.address2 = value;
		return this;
	}

	public ContactModel setHome2(String value) {
		this.home2 = value;
		return this;
	}

	public ContactModel setBday(String value) {
		int temp = Integer.parseInt(value);
		if (temp > 0 && temp < 32) {
			this.bDay = value;
		}
		return this;
	}

	public ContactModel setBday(int value) {
		if (value > 0 && value < 32) {
			this.bDay = "" + value;
		}
		return this;
	}
	
	

	public ContactModel setBmonth(int value) {
		if (value < 1 || value > 12) {
			this.bMonth = monthes[0];
		} else {
			this.bMonth = monthes[value];
		}

		return this;
	}

	public ContactModel setBmonth(String value) {
		if (value != null && Arrays.asList(monthes).contains(value)) {
			this.bMonth = value;
		} else {
			this.bMonth = monthes[0];
		}
		return this;
	}

	public ContactModel setBmonth() {

		this.bMonth = monthes[0];

		return this;
	}

	public ContactModel setBYear(int value) {
		this.bYear = "" + value;
		return this;
	}

	public ContactModel setBYear(String value) {
		this.bYear = value;
		return this;
	}

}
